/*
 * @Description: 
 * @Version: 1.0
 * @Autor: Crystal
 * @Date: 2021-04-02 16:45:45
 * @LastEditors: Crystal
 * @LastEditTime: 2021-04-02 16:50:05
 */
#include "elog_start.h"
#include "elog.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void elog_init_start(void)
{
    /* close printf buffer */
    setbuf(stdout, NULL);
    
    /* initialize EasyLogger */
    elog_init();
    
    /* set EasyLogger log format */
    elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_ALL);
    elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME);
    elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME | ELOG_FMT_P_INFO | ELOG_FMT_P_INFO);
    elog_set_fmt(ELOG_LVL_VERBOSE,  ~ELOG_FMT_ALL);
#ifdef ELOG_COLOR_ENABLE
    elog_set_text_color_enabled(true);
#endif
    
    /* 
        output log's level  
        ELOG_LVL_ASSERT(0), ELOG_LVL_ERROR ELOG_LVL_WARN
        ELOG_LVL_INFO(3) ELOG_LVL_DEBUG(4), ELOG_LVL_VERBOSE(5)
    */
    elog_set_filter_lvl(ELOG_LVL_DEBUG);

    /* start EasyLogger */
    elog_start();

    /* dynamic set enable or disable for output logs (true or false) */
//    elog_set_output_enabled(false);
    /* dynamic set output logs's level (from ELOG_LVL_ASSERT to ELOG_LVL_VERBOSE) */
//    elog_set_filter_lvl(ELOG_LVL_WARN);
    /* dynamic set output logs's filter for tag */
//    elog_set_filter_tag("main");
    /* dynamic set output logs's filter for keyword */
//    elog_set_filter_kw("Hello");
    /* dynamic set output logs's tag filter */
//    elog_set_filter_tag_lvl("main", ELOG_LVL_WARN);

}